package com.minelx.woods.server.controller;

import com.alibaba.fastjson.JSONObject;
import com.minelx.woods.server.entity.Users;
import com.minelx.woods.server.perspective.Authenticated;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

import java.util.Map;

import static org.springframework.http.ResponseEntity.ok;

@RestController
public class UserController {
	private final Users users;

	public UserController(Users users) {
		this.users = users;
	}

	@PostMapping("user")
	ResponseEntity<?> register(@RequestBody JSONObject body) {
		users.register(
				body.getString("user"),
				body.getString("password"));
		return ok().build();
	}
}
